const gulp = require('gulp');
const concat = require('gulp-concat');
const watch = require('gulp-watch');
const  uglify = require('gulp-uglify');

gulp.task('base', async () => {
    gulp.src([
        './packages/hydra/lib/utils/*.js',
        './packages/hydra/lib/core/*.js',
        './packages/hydra/lib/hydra/*.js',
        './packages/hydra/index.js'])
        .pipe(concat('base.js'))
        .pipe(uglify())
        .pipe(gulp.dest("./dist"));
});

gulp.task('at', async () => {
    gulp.src([
        './packages/at/core/classes/*.js',
        './packages/at/core/3d/*.js',
        './packages/at/core/mods/*.js',
        './packages/at/core/*.js',
        './packages/at/lib/**/*.js',
        './packages/at/index.js'])
        .pipe(concat('at.js'))
        .pipe(gulp.dest("./dist"));
});

gulp.task('view', async () => {
    gulp.src([
        './packages/at/main/**/*.js',
        './packages/at/view.js'])
        .pipe(concat('view.js'))
        
        .pipe(gulp.dest("./dist"));
})


gulp.task('demo', async () => {
    gulp.src([
        './packages/at/demo/**/*.js',
        './packages/at/demo.js'])
        .pipe(concat('view.js'))
        .pipe(gulp.dest("./dist"));
})

gulp.task('lbm', async () => {
    gulp.src([
        './packages/at/lbm/**/*.js',
        './packages/at/lbm.js'])
        .pipe(concat('view.js'))
        .pipe(gulp.dest("./dist"));
})



gulp.task('watch', ()=>{
    watch([
        './packages/at/demo/**/*.js',
        './packages/at/demo.js'
    ],gulp.series(['base','at','demo']))
})


gulp.task('watch:view', ()=>{
    watch([
        './packages/at/main/**/*.js',
        './packages/at/index.js',
        './packages/at/view.js'
    ],gulp.series(['base','at','view']))
})



gulp.task('watch:lbm', ()=>{
    watch([
        './packages/at/lib/**/*.js',
        './packages/at/lbm/**/*.js',
        './packages/at/lbm.js'
    ],gulp.series(['base','at','lbm']))
})